package com.atguigu.dga.governance.assessor.spec;

import com.atguigu.dga.governance.assessor.Assessor;
import com.atguigu.dga.governance.bean.AssessParam;
import com.atguigu.dga.governance.bean.GovernanceAssessDetail;
import com.atguigu.dga.governance.bean.GovernanceMetric;
import com.atguigu.dga.meta.bean.TableMetaInfo;
import com.atguigu.dga.meta.constants.MetaConst;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

@Component("HAS_BUSI_OWNER")
public class HasBusiOwnerAssessor  extends Assessor {

    @Override
    public void checkProblem(AssessParam assessParam, GovernanceAssessDetail governanceAssessDetail) {
        TableMetaInfo tableMetaInfo = assessParam.getTableMetaInfo();
        String governanceUrl = assessParam.getGovernanceMetric().getGovernanceUrl();
        if (tableMetaInfo.getTableMetaInfoExtra().getBusiOwnerUserName()==null
                ||tableMetaInfo.getTableMetaInfoExtra().getBusiOwnerUserName().trim().length()==0
                ||tableMetaInfo.getTableMetaInfoExtra().getBusiOwnerUserName().equals(MetaConst.OWNER_UNSET)){
            //设置考评结果
            governanceAssessDetail.setAssessScore(BigDecimal.ZERO);
            governanceAssessDetail.setAssessProblem("业务负责人未填写");
            governanceAssessDetail.setGovernanceUrl(governanceUrl.replace("{tableId}",tableMetaInfo.getId().toString()));

        }
    }
}
